package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.SheJiShi;
import com.ysd.util.DBManager;

public class SheJiShiDaoImpl {
	public List<SheJiShi> getSheJiShiList() {
		List<SheJiShi> list = new ArrayList<SheJiShi>();
		Statement st = null;
		ResultSet rs = null;
		
		Connection conn = DBManager.getConnection();
		try {
			st = conn.createStatement();
			// 3.SQL语句
			String sql = "select * from shejishi";
			// 4.执行SQL语句，返回结果集
			rs = st.executeQuery(sql);
			while (rs.next()) {
				int sheJiShiid = rs.getInt("sheJiShiid");
				String sheJiShiName = rs.getString("sheJiShiName");
				String zhiCheng = rs.getString("zhiCheng");
				String sheJiShiTX = rs.getString("sheJiShiTX");
				SheJiShi sjs = new SheJiShi(sheJiShiid, sheJiShiName, zhiCheng, sheJiShiTX);
				list.add(sjs);// 把user对象存入到list中

			}
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
